<template>
  <view class="article-detail-container">
    <!-- 头部图片 -->
    <swiper class="article-img-swiper" :indicator-dots="true" :autoplay="false">
      <swiper-item v-for="(img, idx) in article.img" :key="idx">
        <image class="article-img" :src="img" mode="aspectFill" />
      </swiper-item>
    </swiper>
    <!-- 标题 -->
    <view class="article-title">{{ article.title }}</view>
    <!-- 内容 -->
    <view class="article-content">{{ article.content }}</view>
    <!-- 评论区 -->
    <view class="comment-section">
      <view class="comment-title">评论 {{ comments.length }}</view>
      <view class="comment-list">
        <view class="comment-item" v-for="(item, idx) in comments" :key="idx">
          <image class="avatar" :src="item.avatar" />
          <view class="comment-main">
            <view class="comment-user">{{ item.user }}</view>
            <view class="comment-text">{{ item.text }}</view>
            <view class="comment-meta">{{ item.time }}</view>
          </view>
        </view>
      </view>
      <view class="comment-input-bar">
        <input class="comment-input" placeholder="说点什么..." v-model="inputValue" />
        <button class="comment-btn" @click="submitComment">发送</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      article: {
        img: [
          'https://dummyimage.com/600x300/eee/333&text=Article1',
          'https://dummyimage.com/600x300/ccc/333&text=Article2',
          'https://dummyimage.com/600x300/aaa/333&text=Article3'
        ],
        title: '买了cursor不知道开发什么网站app了',
        content: '有没有想法的，搭建自己的工具网站、app扩展，#网站设计 #程序员 #软件开发...'
      },
      comments: [
        { user: 'AIGC小绵阳', avatar: 'https://dummyimage.com/40x40/19cf8a/fff', text: '有同感！', time: '06-10 北京' },
        { user: '月隐', avatar: 'https://dummyimage.com/40x40/333/fff', text: '交个朋友，一起交流编程呀', time: '06-10 山西' }
      ],
      inputValue: ''
    }
  },
  methods: {
    submitComment() {
      if (!this.inputValue.trim()) return;
      this.comments.push({
        user: '我',
        avatar: 'https://dummyimage.com/40x40/888/fff',
        text: this.inputValue,
        time: '刚刚'
      });
      this.inputValue = '';
    }
  }
}
</script>

<style lang="less">
.article-detail-container {
  background: #fff;
  min-height: 100vh;
  padding-bottom: 100rpx;
}
.article-img-swiper {
  width: 100vw;
  height: 200px;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
}
.article-img {
  width: 100vw;
  height: 200px;
  object-fit: cover;
  display: block;
}
.article-title {
  font-size: 22px;
  font-weight: bold;
  color: #222;
  margin: 18px 18px 10px 18px;
}
.article-content {
  font-size: 16px;
  color: #444;
  margin: 0 18px 18px 18px;
  line-height: 1.8;
}
.comment-section {
  background: #fafbfc;
  border-radius: 16px 16px 0 0;
  margin-top: 18px;
  padding: 18px 0 0 0;
}
.comment-title {
  font-size: 16px;
  color: #222;
  font-weight: bold;
  margin-left: 18px;
  margin-bottom: 10px;
}
.comment-list {
  margin: 0 12px 12px 12px;
}
.comment-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 14px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 10px;
}
.comment-main {
  flex: 1;
}
.comment-user {
  font-size: 14px;
  color: #333;
  font-weight: bold;
}
.comment-text {
  font-size: 15px;
  color: #444;
  margin: 2px 0 2px 0;
}
.comment-meta {
  font-size: 12px;
  color: #aaa;
}
.comment-input-bar {
  display: flex;
  align-items: center;
  padding: 10px 12px 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
  position: fixed;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 10;
}
.comment-input {
  flex: 1;
  height: 36px;
  border-radius: 18px;
  border: 1px solid #eee;
  padding: 0 14px;
  font-size: 15px;
  background: #f7f7f7;
  margin-right: 10px;
}
.comment-btn {
  background: #19cf8a;
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 0 18px;
  height: 36px;
  font-size: 15px;
}
</style> 